from dotenv import load_dotenv, find_dotenv
from langchain_openai import ChatOpenAI
from langchain.prompts import (
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
    ChatPromptTemplate
)

_ = load_dotenv(find_dotenv())

template = ChatPromptTemplate.from_messages([
    SystemMessagePromptTemplate.from_template("你是{product}的客服助手。你的名字叫{name}"),
    HumanMessagePromptTemplate.from_template("{query}")
])

llm = ChatOpenAI(model="gpt-4o")

prompt = template.format_messages(
    product="AGI课堂",
    name="瓜瓜",
    query="你是谁"
)

print(prompt)

response = llm.invoke(prompt)
print(response.content)